package com.data.codegenerate.generate.util;

import com.data.codegenerate.database.util.DbConvertDef;
import com.data.codegenerate.generate.pojo.ColumnVo;
import org.apache.commons.lang.StringUtils;

public class TableConvert {
    public static String a(String str) {
        if ("YES".equals(str) || "yes".equals(str) || "y".equals(str) || DbConvertDef.a.equals(str) || "f".equals(str)) {
            return DbConvertDef.a;
        }
        if ("NO".equals(str) || DbConvertDef.b.equals(str) || "no".equals(str) || "n".equals(str) || "t".equals(str)) {
            return DbConvertDef.b;
        }
        return null;
    }

    public static String b(String str) {
        if (StringUtils.isBlank(str)) {
            return "";
        }
        return str;
    }

    public static String c(String str) {
        return "'" + str + "'";
    }

    public static String d(String str) {
        String[] split = str.split("_");
        String str2 = "";
        int length = split.length;
        for (int i = 0; i < length; i++) {
            if (i > 0) {
                String lowerCase = split[i].toLowerCase();
                str2 = str2 + (lowerCase.substring(0, 1).toUpperCase() + lowerCase.substring(1, lowerCase.length()));
            } else {
                str2 = str2 + split[i].toLowerCase();
            }
        }
        return str2;
    }

    public static void a(ColumnVo columnVo) {
        String fieldType = columnVo.getFieldType();
        String scale = columnVo.getScale();
        columnVo.setClassType("inputxt");
        if (DbConvertDef.b.equals(columnVo.getNullable())) {
            columnVo.setOptionType("*");
        }
        if ("datetime".equals(fieldType) || fieldType.contains("time")) {
            columnVo.setClassType("easyui-datetimebox");
        } else if ("date".equals(fieldType)) {
            columnVo.setClassType("easyui-datebox");
        } else if (fieldType.contains("int")) {
            columnVo.setOptionType("n");
        } else if ("number".equals(fieldType)) {
            if (StringUtils.isNotBlank(scale) && Integer.parseInt(scale) > 0) {
                columnVo.setOptionType("d");
            }
        } else if ("float".equals(fieldType) || "double".equals(fieldType) || "decimal".equals(fieldType)) {
            columnVo.setOptionType("d");
        } else if ("numeric".equals(fieldType)) {
            columnVo.setOptionType("d");
        }
    }

    public static String a(String str, String str2, String str3) {
        if (str.contains("char")) {
            return "java.lang.String";
        }
        if (str.contains("int")) {
            return "java.lang.Integer";
        }
        if (str.contains("float")) {
            return "java.lang.Float";
        }
        if (str.contains("double")) {
            return "java.lang.Double";
        }
        if (str.contains("number")) {
            if (StringUtils.isNotBlank(str3) && Integer.parseInt(str3) > 0) {
                return "java.math.BigDecimal";
            }
            if (!StringUtils.isNotBlank(str2) || Integer.parseInt(str2) <= 10) {
                return "java.lang.Integer";
            }
            return "java.lang.Long";
        } else if (str.contains("decimal")) {
            return "java.math.BigDecimal";
        } else {
            if (str.contains("date") || str.contains("time")) {
                return "java.util.Date";
            }
            if (str.contains("blob")) {
                return "byte[]";
            }
            if (str.contains("clob")) {
                return "java.sql.Clob";
            }
            if (str.contains("numeric")) {
                return "java.math.BigDecimal";
            }
            return "java.lang.Object";
        }
    }
}
